function check()
{
	if(confirm("请确认你要删除的记录！"))
		return true;
	else
		return false;
}

function alert_del()
{
	if(confirm("请确认你要删除的记录！"))
		return true;
	else
		return false;
}

function checkSave()
{
        if(confirm("请确认是否是需要保存信息！"))
                return true;
        else
                return false;
}

function alert_confirm(str) {
	if(confirm(str))
		return true;
	else
		return false;
}


//'d' 天数, 'm' 秒数
function DateDiff(typeid,s1,s2) {
	var d1 = new Date(); // current date
	var d2 = new Date();
	dt1 = s1.split(" ");
	dt2 = s2.split(" ");

	datepart1 = dt1[0].split("-");
	d1.setYear(datepart1[0]);
	d1.setMonth(datepart1[1]);
	d1.setDate(datepart1[2]);

	datepart1 = dt2[0].split("-");
	d2.setYear(datepart1[0]);
	d2.setMonth(datepart1[1]);
	d2.setDate(datepart1[2]);

	if(typeid == 'm') {
		datepart1 = dt1[1].split(":");
		d1.setHours(datepart1[0]);
		d1.setMinutes(datepart1[1]);
		d1.setSeconds(datepart1[2]);

		datepart1 = dt2[1].split(":");
		d2.setHours(datepart1[0]);
		d2.setMinutes(datepart1[1]);
		d2.setSeconds(datepart1[2]);
	}

	delta = d1.getTime() - d2.getTime(); // in msecs
	if(typeid == 'd') {
		delta /= (1000 * 60 * 60 * 24);
	}
	else if(typeid == 'm') {
		delta /= (1000 * 60);
	}
	return delta;

}

function alertValid(i) {
	if(!isValid(i.value)) {
		alert("错误提示：输入的信息有非法的字符存在，只可以输入a-z,A-Z,0-9,_。");
		i.focus();
		//i.select();
		return false;
	}
	return true;
}
//检测是否有非法的字符
function isValid(myint)
{

  var checkOK = "0123456789_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var checkStr = myint;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    return (false);
  }

  return (true);
}

//选择和清除所有的复选框
function checkall(form)
{
	for(var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
		if(form.elements[i].type=='checkbox' && form.chkall.value == '全选')
		{
			e.checked = true;
		}
		else if(form.elements[i].type=='checkbox')
			e.checked = false;
	}

	if(form.chkall.value == '全选')
		form.chkall.value = '清除';
	else
		form.chkall.value = '全选';
}

//判断是否是日期
function isdate(strDate){

	//var re=/^\d{4}-\d{1,2}-\d{1,2}$/;
	//var r=strDate.match(re);
	//if (r==null) return false;


   var strSeparator = "-"; //日期分隔符
   var strDateArray;
   var intYear;
   var intMonth;
   var intDay;
   var boolLeapYear;

   strDateArray = strDate.split(strSeparator);

   if(strDateArray.length!=3) return false;

   intYear = parseInt(strDateArray[0],10);
   intMonth = parseInt(strDateArray[1],10);
   intDay = parseInt(strDateArray[2],10);

   if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay)) return false;

   if(intMonth>12||intMonth<1) return false;

   if((intMonth==1||intMonth==3||intMonth==5||intMonth==7||intMonth==8||intMonth==10||intMonth==12)&&(intDay>31||intDay<1)) return false;

   if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30||intDay<1)) return false;

   if(intMonth==2){
      if(intDay<1) return false;

      boolLeapYear = false;
      if((intYear%100)==0){
         if((intYear%400)==0) boolLeapYear = true;
      }
      else{
         if((intYear%4)==0) boolLeapYear = true;
      }

      if(boolLeapYear){
         if(intDay>29) return false;
      }
      else{
         if(intDay>28) return false;
      }
   }

   return true;
}

function alertDate(input) {
	strDate = input.value;
	if (strDate == '') return;
	if(!isdate(strDate)) {
		alert("请输入正确地的日期格式[YYYY-MM-DD]。");
		input.focus();
		//input.select();
	}
}

function checkemail(input) {
	str = input.value;
	if ( str!="" )
	{
	if (str.indexOf('@', 0) == -1)
	{
		alert("这不是正确的e-mail address! 请再输入一次!");
		input.focus();
		input.select();}
	}
}

function isEmail(input) {
	str = input.value;
	if ( str=="" ) {
		return false;
	}
	if (str.indexOf('@', 0) == -1) {
		return false;
	}
	return true;
}

function callpage(htmlurl) {
	window.open(htmlurl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=2,width=550,height=500');
	return false;
}

function isInt(e)
{
    var charCode=e.keyCode;
	status=charCode;
	if(charCode==45) return true;
	if(charCode>31 &&(charCode<48||charCode>57)) {
		//alert("请输入数字.");
		return false;
	}
	return true;
}

function checkInt(input) {
	var str = input.value;
	if(str.substring(0,1)=='-') str = str.substring(1,str.length);
	var re=/^\d{0,8}$/;
	var r=str.match(re);
	if (r == null) {
		alert('错误提示：请输入正确的数字！');
		input.focus();
		input.select();
	}

}

function isNumber(input) {
	var str = input.value;
	if (str=='') return true;
	var re=/^\d{1,8}$|\.\d{1,2}$/;
	var r=str.match(re);
	if (r==null) {
		alert("错误提示：请输入正确的数值，小数点后保留两位小数。");
		input.focus();
		input.select();
	}
	return true;
}

function checkNumber(e) {
	var charCode = e.keyCode;
	if(charCode==45) return true;
	if(charCode==46) return true;
	if(charCode>31 &&(charCode<48||charCode>57)) {
		//alert("请输入数字.");
		return false;
	}
	return true;
}


function copyright() {
	document.write("<br><center>Copyright 2001-2002版权所有，All right Reserved </center><br>");
}

function setSubject(s) {
	document.write("<table width='100%' border=0 cellspacing=1 cellpadding=1 align=center><tr><td><img src='../images/arron1.gif'><font color=#f67a00><b>"+s+"</b></font></td></tr></table>");
}

//显示、隐藏Search
function toSearch(){
	var args=toSearch.arguments;
	theObj=eval("document.all[\'"+args[0]+"\']");
	if(theObj) {
		if(theObj.style.visibility=='visible')
			theObj.style.visibility = 'hidden';
		else
			theObj.style.visibility = 'visible';
	}
}

function openCalender() {
	var width = 230;
	var height = 210;
	var lastMouseX;
	var lastMouseY;
	var features;
	var e,FileName;
	FileName = arguments[0];
	if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
	lastMouseX = e.screenX;
	lastMouseY = e.screenY;
	if (lastMouseX - width < 0) {
		lastMouseX = width;
	}
	if (lastMouseY + height > screen.height) {
		lastMouseY -= (lastMouseY + height + 50) - screen.height;
	}
	lastMouseX -= width;
	lastMouseY += 10;
	features = "width="+width+",height="+height+",status=no,resizable=no,"
	features +=	"screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
	vWinCal = window.open(FileName, "Calendar", features,false);
	vWinCal.focus();
}

function setComboxValue() {
	var Dwidth = 190;
	var Dheight = 260;

	var lastMouseX;
	var lastMouseY;
	var features;
	var FileName,formElt,showformElt, e;

	FileName = arguments[0];
	formElt = arguments[1];
	showformElt = arguments[2];
	if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
	lastMouseX = e.screenX;
	lastMouseY = e.screenY;

	if (lastMouseX - Dwidth < 0) {
		lastMouseX = Dwidth;
	}
	if (lastMouseY + Dheight > screen.height) {
		lastMouseY -= (lastMouseY + Dheight + 50) - screen.height;
	}
	lastMouseX -= Dwidth;
	lastMouseY += 10;
	features = "dialogWidth:"+Dwidth+"px;dialogHeight:"+Dheight+"px; scroll:0; help:0; status:No; fullscreen;";
	features +=	"screenX:" + lastMouseX + ";dialogLeft:" + lastMouseX + ";screenY:" + lastMouseY + ";dialogTop:" + lastMouseY;



	rv=window.showModalDialog(FileName,null,features);
	//rv=window.showModalDialog(FileName,null,"dialogWidth:"+Dwidth+"px;dialogHeight:"+Dheight+"px;center:1;scroll:0;help:0;status:0");
	if ( rv == null) return;
	if ( showformElt != "" && formElt != "") {
		var i = formElt.indexOf('.');
		var formName,formEltName;
		//设置显示的值
		if( rv[0] == "") {
			//清空ID
			formName = formElt.substring(0,i);
			formEltName = formElt.substring(i+1);
			document.forms[formName].elements[formEltName].value = "";
			//清空显示的值
			formName = showformElt.substring(0,i);
			formEltName = showformElt.substring(i+1);
			document.forms[formName].elements[formEltName].value = "";
		}
		else {
			//设置ID
			formName = formElt.substring(0,i);
			formEltName = formElt.substring(i+1);

			document.forms[formName].elements[formEltName].value = ignoreSpaces(rv[0]);
			//设置显示的值
			formName = showformElt.substring(0,i);
			formEltName = showformElt.substring(i+1);
			document.forms[formName].elements[formEltName].value = ignoreSpaces(rv[1]);
		}
	}
	return;
}

//清除空格
function ignoreSpaces(string) {
	var temp = "";
	string = '' + string;
	splitstring = string.split("　");
	for(i = 0; i < splitstring.length; i++)
		temp += splitstring[i];
	return temp;
}

var objPrevElement = null;
function ChangeColor() {
	source=event.srcElement;

	if(objPrevElement!=null && objPrevElement.tagName=='TR')
	objPrevElement.style.backgroundColor='#EEEEEE';

	//for(i in document.all){
	//	if(document.all[i].t==1){//用户触发:重新设置属性
	//		document.all[i].style.backgroundColor='#EEEEEE';
	//	}
	//}
	//if(source.tagName=="INPUT") {
		//if(source.checked)
	//}
	if(source.tagName=="INPUT") return;
	if(source.tagName=="TABLE") return;
	while(source.tagName!="TR") {
		source=source.parentElement;
	}
	if (source.style.backgroundColor!='#CFDFFF'&&source.id!="ignore") {
		source.style.backgroundColor='#CFDFFF';
		objPrevElement=event.srcElement.parentElement;
	} else {
		source.style.backgroundColor='#EEEEEE';
	}
}

//按取消关闭窗口
function onClose() {
	if(event.keyCode==27) window.close();
	return true;
}


function openSelect() {
	var width = 500;
	var height = 400;
	//var lastMouseX;
	//var lastMouseY;
	var features;
	var e,FileName;
	FileName = arguments[0];
	//if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
	//lastMouseX = e.screenX;
	//lastMouseY = e.screenY;
	//if (lastMouseX - width < 0) {
	//	lastMouseX = width;
	//}
	//if (lastMouseY + height > screen.height) {
	//	lastMouseY -= (lastMouseY + height + 50) - screen.height;
	//}
	//lastMouseX -= width;
	//lastMouseY += 10;
	features = "width="+width+",height="+height+",status=no,resizable=auto,scrollbars=yes"
	//features +=	"screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
	selWin = window.open(FileName, "selectWindow", features,false);
	selWin.focus();
}


var timer;
function scrollwindowdown() {
	currentpos=frmchild.document.body.scrollTop;
	frmchild.window.scroll(0,currentpos+3);
}
function scrollwindowup() {
	currentpos=frmchild.document.body.scrollTop;
	frmchild.window.scroll(0,currentpos-3);
}
function startScroll(str)  {
	if(str == "up")
		timer=setInterval("scrollwindowup()",1);
	else
		timer=setInterval("scrollwindowdown()",1);
}
function endScroll(){
	clearInterval(timer);
}

function Iscompare(value1,value2)
{
	if (value1 == value2)
	{
		return true;
	}
	else
	{
		return false;
	}
}
//验证电话号码
function isTelephoneCode(codeString)
{
	var stringTemp = "";	
	var lengthTemp = 0;	
	var sign=0;		
	  	
	stringTemp = javaTrim(codeString);
	lengthTemp = stringTemp.length;
	  	
	if(lengthTemp!=0)
	{   		
		for (i=0; i<lengthTemp; i++)
		{
			if(isNaN(stringTemp.charAt(i)))
			{
				//当发现第一个字符不是数值型，或有字符不是间隔符"-"时出错
				if (i==0||stringTemp.charAt(i) != "-")
				{
					return(false);
				} 
				else
				{
					//置间隔符计数器加1
					sign=sign+1;
				}
			 } //if(isNaN(stringTemp.charAt(i)))
		}//end for      
	}
	else
	{
		return(false);
	}
	
	if (stringTemp != "")
	{
		//检查间隔符计数器只能是一个，否则出错
	//if (sign > 1)
	//{
	// 	return(false);
	//} 
	}
  return(true);
} 
	
function fucCheckNUM(NUM)
	{
	var i,j,strTemp;
	strTemp="0123456789";
	if ( NUM.length== 0)
	return 0
	for (i=0;i<NUM.length;i++)
	{
	j=strTemp.indexOf(NUM.charAt(i)); 
	if (j==-1)
	{
	//说明有字符不是数字
	return false;
	}
	}
	//说明是数字
	return true;
	}
//--------------------------------------------------
//函数名：fucCheckNUM     
//功能介绍：检查是否为数字 ,可以包含“.”号   
//参数说明：要检查的数字     
//返回值：true为是数字，false为不是数字     
function fucCheckNUM_1(NUM){     
	var i,j,strTemp;     
	strTemp="-0123456789.";     
	if (NUM.length==0) return true;     
	for (i=0;i<NUM.length;i++){     
		j=strTemp.indexOf(NUM.charAt(i));     
		if (j==-1){     
			//说明有字符不是数字     
			return false;     
		}     
	}     
	//说明是数字     
	return true;     
}     
    